$(function() {

    layui.use('carousel', function() {
        let carousel = layui.carousel;

        slideshow()
            // 加载轮播图数据
        function slideshow() {
            $.ajax({
                url: "http://localhost:8888/api/swipers",
                success: function(res) {
                    // console.log(res);
                    if (res.status === 0) {
                        let arr = [];
                        res.data.forEach(item => {
                            arr.push(`
                            <li class="img-effect">
                    <a href="javascript:;">
                        <img src="${"http://localhost:8888/uploads/"+item.swiperimg}" alt="">
                    </a>
                     </li>
                            `)
                        })
                        $("#kr_carousel ul ").html(arr.join(''))

                        // //建造实例
                        carousel.render({
                            elem: '#kr_carousel',
                            height: "300px",
                            width: '720px', //设置容器宽度

                            arrow: 'always' //始终显示箭头
                                //,anim: 'updown' //切换动画方式
                        });
                    }
                }
            })

        }

        interlinkage()

        function interlinkage() {
            $.ajax({
                url: 'http://localhost:8888/api/links',
                success: function(res) {
                    console.log(res);
                    let arr = [`  <dt>合作伙伴</dt>`];
                    res.data.forEach(item => {
                        arr.push(`
                        <dd>
                        <a href="javascript:;">
                            <img src="${"http://localhost:8888/uploads/"+item.linkicon}" alt="">
                        </a>
                    </dd>
                        `)
                    })
                    $(".kr_collaborator").html(arr.join(''))
                }
            })
        }

    });

})